package com.bravo.mvpkotlin.ui.detail

import com.bravo.mvpkotlin.data.DataManager
import io.reactivex.Scheduler
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers

/**
 * Created by Administrator on 2017/6/24.
 */

class DetailPersenter(val detailViews : DetailViews ,val dataManager: DataManager){
    fun getRepos(reposUrl: String) {
        dataManager.getRepos(reposUrl)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .doOnSubscribe { detailViews.startLoading() }
                .doOnError { detailViews.stopLoading() }
                .subscribe { detailViews.showRepo(it) }
    }
}